package main

//#link: https://leetcode-cn.com/problems/binary-subarrays-with-sum/
func main() {

}

/**
 * @Description: 利用前缀和
 */
func numSubarraysWithSum(nums []int, goal int) (ans int) {
	cnt := make(map[int]int)
	sum := 0
	for _, num := range nums {
		cnt[sum]++
		sum += num
		ans += cnt[sum-goal]
	}
	return
}
